<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <script type="text/javascript" src="${ctxStatic}/ajaxfileupload/ajaxfileupload.js"></script>
	<title>产品品牌管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/product/brand/proBrand/">产品品牌列表</a></li>
		<li class="active"><a href="${ctx}/product/brand/proBrand/form?id=${proBrand.id}">产品品牌<shiro:hasPermission name="product:brand:proBrand:edit">${not empty proBrand.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="product:brand:proBrand:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="proBrand" action="${ctx}/product/brand/proBrand/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">品牌名称：</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">所属目录：</label>
			<div class="controls">
				<sys:treeselect id="proCatalog" name="proCatalog.id" value="${proBrand.proCatalog.id}" labelName="proCatalog.name" labelValue="${proBrand.proCatalog.name}"
					title="所属目录" url="/product/catalog/proCatalog/treeData" extId="${proCatalog.id}" cssClass="" allowClear="true"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">广告语：</label>
			<div class="controls">
				<form:input path="slogan" htmlEscape="false" maxlength="500" class="input-xlarge "/>
			</div>
		</div>
			<div class="control-group">
			<label class="control-label">品牌logo：</label>
			<div class="controls">
				<form:hidden id="logo" path="logo" htmlEscape="false" maxlength="255" class="input-xlarge"/>
				<input name="logoFileName" id="logoFileName" type="text" readonly="readonly" style="width: 360px; margin-bottom: 0px;" />
				<input name="logoFile" id="logoFile" type="file" style="display: none" />
				<input id="fileSelect" class="btn btn-primary" type="button" value="选择文件" onclick="$('#logoFile').click();" />
				<input id="fileUpload" class="btn" type="button" value="上传" />
				<ol id="nameImagePreview"><li><img id="logoImg" src="${proBrand.fastdfs_file_url}${proBrand.logo}" style="width:auto;height:100px;margin:10px;"></li></ol>
				<script type="text/javascript">
						$(document).ready(function() {
							$("#logoFile").live('change', function(){
								var fileValue = document.getElementById("logoFile").files; 
								$('#logoFileName').val(fileValue[0].name);  
							});  
							
							$("#fileUpload").click(function() {
						      	if($("#logoFileName").val()==""){
									top.$.jBox.tip('请选择上传文件！','warning');
									return;
								}	
						      	loading('正在上传文件，请稍等...');
						        $.ajaxFileUpload({
						          url : '${ctx}/product/brand/proBrand/uploadLogoFile',//处理图片脚本
						          secureuri : false,
						          data:{},
						          type:"post",
						          fileElementId : 'logoFile',//file控件id
						          dataType : "json",
								  success: function(data){
									if(data.success){
										top.$.jBox.tip('上传文件成功！','info');
										$('#logo').val(data.proBrand.logo);  
										$("#logoImg").attr('src',data.proBrand.fastdfs_file_url+data.proBrand.logo); 
										$('#logoFileName').val("");  
									}else{
										top.$.jBox.tip('上传文件失败！','warning');
									}},
					                error: function (data, status, e)//服务器响应失败处理函数
					                {
					                    top.$.jBox.tip('上传文件失败！','warning');
					                }
						          })
						       });
							
						});
				</script>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">是否推荐：</label>
			<div class="controls">
				<form:radiobuttons path="isRecommend" items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false" class=""/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">描述：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="1000" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="product:brand:proBrand:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>